<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java缓存技术深度解析：Guava Cache vs Caffeine vs Redis</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            color: #222;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0,0,0,0.1);
        }
        .highlight {
            position: relative;
        }
        .highlight:after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(118, 75, 162, 0.2);
            z-index: -1;
            transform: scaleX(1.05);
            transform-origin: bottom left;
            transition: transform 0.3s ease;
        }
        .highlight:hover:after {
            transform: scaleX(1.1) scaleY(1.3);
        }
        .code-block {
            background: #2d3748;
            color: #f7fafc;
            border-radius: 0.5rem;
            overflow: hidden;
        }
        .code-header {
            background: #1a202c;
            padding: 0.5rem 1rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .tech-icon {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            margin-right: 1rem;
            flex-shrink: 0;
        }
        .comparison-table {
            border-collapse: separate;
            border-spacing: 0;
            width: 100%;
        }
        .comparison-table th, .comparison-table td {
            padding: 1rem;
            text-align: left;
            border-bottom: 1px solid #e2e8f0;
        }
        .comparison-table th {
            background-color: #f8fafc;
            font-weight: 600;
        }
        .comparison-table tr:hover td {
            background-color: #f7fafc;
        }
        .feature-tag {
            display: inline-block;
            padding: 0.25rem 0.5rem;
            border-radius: 9999px;
            font-size: 0.75rem;
            font-weight: 600;
            margin-right: 0.5rem;
            margin-bottom: 0.5rem;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 md:py-32 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6 leading-tight">Java缓存技术深度解析</h1>
            <p class="text-xl md:text-2xl opacity-90 mb-8 max-w-3xl mx-auto">探索Guava Cache、Caffeine和Redis的核心特性与最佳实践</p>
            <div class="flex flex-wrap justify-center gap-4">
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full font-medium">高性能</span>
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full font-medium">分布式缓存</span>
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full font-medium">内存管理</span>
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full font-medium">持久化</span>
            </div>
        </div>
    </section>

    <!-- Introduction -->
    <section class="py-16 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto">
            <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                <div class="p-8">
                    <h2 class="text-3xl font-bold mb-6 text-gray-800">现代应用中的缓存技术</h2>
                    <p class="text-lg text-gray-700 mb-6">在现代应用开发中，缓存技术已成为优化系统性能的关键手段。通过缓存，我们能够有效减少数据库或远程服务的访问次数，从而显著提高响应速度和系统的吞吐量。缓存技术的选择直接影响到系统的可扩展性、可靠性以及开发的复杂度。</p>
                    
                    <div class="flex flex-col md:flex-row gap-6 mt-8">
                        <div class="flex-1 bg-gray-50 p-6 rounded-lg">
                            <div class="flex items-center mb-4">
                                <div class="tech-icon bg-purple-100 text-purple-600">
                                    <i class="fas fa-memory text-2xl"></i>
                                </div>
                                <h3 class="text-xl font-semibold">Guava Cache</h3>
                            </div>
                            <p class="text-gray-700">Google提供的轻量级本地缓存解决方案，适合单机环境使用。</p>
                        </div>
                        <div class="flex-1 bg-gray-50 p-6 rounded-lg">
                            <div class="flex items-center mb-4">
                                <div class="tech-icon bg-blue-100 text-blue-600">
                                    <i class="fas fa-bolt text-2xl"></i>
                                </div>
                                <h3 class="text-xl font-semibold">Caffeine</h3>
                            </div>
                            <p class="text-gray-700">Guava Cache的后继者，在高并发环境下表现更加出色。</p>
                        </div>
                        <div class="flex-1 bg-gray-50 p-6 rounded-lg">
                            <div class="flex items-center mb-4">
                                <div class="tech-icon bg-red-100 text-red-600">
                                    <i class="fas fa-server text-2xl"></i>
                                </div>
                                <h3 class="text-xl font-semibold">Redis</h3>
                            </div>
                            <p class="text-gray-700">广泛使用的分布式缓存系统，支持多种数据结构和持久化存储。</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Guava Cache Section -->
    <section class="py-16 px-4 sm:px-6 lg:px-8 bg-white">
        <div class="max-w-5xl mx-auto">
            <div class="flex flex-col md:flex-row gap-12">
                <div class="md:w-2/3">
                    <div class="flex items-center mb-8">
                        <div class="tech-icon bg-purple-100 text-purple-600 mr-4">
                            <i class="fas fa-memory text-2xl"></i>
                        </div>
                        <h2 class="text-3xl font-bold text-gray-800">Guava Cache</h2>
                    </div>
                    
                    <p class="text-lg text-gray-700 mb-6"><span class="font-semibold">Guava Cache</span> 是 Google 提供的一个轻量级的本地缓存库，它是 Guava 库的一部分。Guava 本身是一个广泛使用的 Java 工具库，提供了许多有用的工具类、集合类以及并发工具。而 Guava Cache 专注于为 Java 应用提供本地内存缓存解决方案。</p>
                    
                    <div class="mb-8">
                        <h3 class="text-2xl font-semibold mb-4 text-gray-800">主要特性</h3>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                            <div class="bg-gray-50 p-4 rounded-lg">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-clock text-purple-500 mr-2"></i> 过期策略
                                </h4>
                                <p class="text-gray-700">支持基于写入和访问时间的自动过期</p>
                            </div>
                            <div class="bg-gray-50 p-4 rounded-lg">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-shield-alt text-purple-500 mr-2"></i> 线程安全
                                </h4>
                                <p class="text-gray-700">内置多线程安全机制，支持高并发访问</p>
                            </div>
                            <div class="bg-gray-50 p-4 rounded-lg">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-database text-purple-500 mr-2"></i> 缓存加载
                                </h4>
                                <p class="text-gray-700">通过CacheLoader实现自动数据加载</p>
                            </div>
                            <div class="bg-gray-50 p-4 rounded-lg">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-chart-bar text-purple-500 mr-2"></i> 统计信息
                                </h4>
                                <p class="text-gray-700">提供缓存命中率等性能统计功能</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-8">
                        <h3 class="text-2xl font-semibold mb-4 text-gray-800">示例代码</h3>
                        <div class="code-block">
                            <div class="code-header">
                                <span class="text-gray-300">Java</span>
                                <button class="text-blue-400 hover:text-blue-300 text-sm">
                                    <i class="far fa-copy mr-1"></i>复制代码
                                </button>
                            </div>
                            <pre class="p-4 overflow-x-auto"><code class="language-java">CacheLoader&lt;String, String&gt; loader = new CacheLoader&lt;String, String&gt;() {
    @Override
    public String load(String key) {
        return fetchDataFromDataSource(key);  // 例如数据库查询
    }
};

Cache&lt;String, String&gt; cache = CacheBuilder.newBuilder()
        .expireAfterWrite(10, TimeUnit.MINUTES)
        .maximumSize(1000)
        .build(loader);</code></pre>
                        </div>
                    </div>
                </div>
                
                <div class="md:w-1/3">
                    <div class="bg-gray-50 p-6 rounded-lg sticky top-8">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800">核心优势</h3>
                        <ul class="space-y-4">
                            <li class="flex items-start">
                                <div class="flex-shrink-0 h-5 w-5 text-purple-500">
                                    <i class="fas fa-check-circle"></i>
                                </div>
                                <p class="ml-3 text-gray-700">易于使用，API设计简洁</p>
                            </li>
                            <li class="flex items-start">
                                <div class="flex-shrink-0 h-5 w-5 text-purple-500">
                                    <i class="fas fa-check-circle"></i>
                                </div>
                                <p class="ml-3 text-gray-700">自动过期与回收，避免内存泄漏</p>
                            </li>
                            <li class="flex items-start">
                                <div class="flex-shrink-0 h-5 w-5 text-purple-500">
                                    <i class="fas fa-check-circle"></i>
                                </div>
                                <p class="ml-3 text-gray-700">智能内存管理，优化缓存大小</p>
                            </li>
                            <li class="flex items-start">
                                <div class="flex-shrink-0 h-5 w-5 text-purple-500">
                                    <i class="fas fa-check-circle"></i>
                                </div>
                                <p class="ml-3 text-gray-700">与现有应用集成简便</p>
                            </li>
                        </ul>
                        
                        <h3 class="text-xl font-semibold mt-8 mb-4 text-gray-800">适用场景</h3>
                        <div class="flex flex-wrap gap-2">
                            <span class="feature-tag bg-purple-100 text-purple-800">单机应用</span>
                            <span class="feature-tag bg-purple-100 text-purple-800">轻量级缓存</span>
                            <span class="feature-tag bg-purple-100 text-purple-800">中小型项目</span>
                            <span class="feature-tag bg-purple-100 text-purple-800">快速开发</span>
                        </div>
                        
                        <div class="mt-8">
                            <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1740727231519-5a752f63-032a-4769-b474-253572e35ef5.png" alt="Guava Cache" class="rounded-lg shadow-md w-full">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Caffeine Section -->
    <section class="py-16 px-4 sm:px-6 lg:px-8 bg-gray-50">
        <div class="max-w-5xl mx-auto">
            <div class="flex flex-col md:flex-row gap-12">
                <div class="md:w-2/3">
                    <div class="flex items-center mb-8">
                        <div class="tech-icon bg-blue-100 text-blue-600 mr-4">
                            <i class="fas fa-bolt text-2xl"></i>
                        </div>
                        <h2 class="text-3xl font-bold text-gray-800">Caffeine</h2>
                    </div>
                    
                    <p class="text-lg text-gray-700 mb-6"><span class="font-semibold">Caffeine</span> 是一个高性能的 Java 本地缓存库，它被设计用来取代传统的 <code>Guava Cache</code>，以满足更高并发和更低延迟的需求。Caffeine 提供了比 <code>Guava Cache</code> 更为高效的缓存管理，尤其是在高并发和大规模缓存使用场景中，其性能表现尤为突出。</p>
                    
                    <div class="mb-8">
                        <h3 class="text-2xl font-semibold mb-4 text-gray-800">先进特性</h3>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                            <div class="bg-white p-4 rounded-lg shadow-sm">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-tachometer-alt text-blue-500 mr-2"></i> 高性能算法
                                </h4>
                                <p class="text-gray-700">采用Window Tiny LRU算法优化内存管理</p>
                            </div>
                            <div class="bg-white p-4 rounded-lg shadow-sm">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-balance-scale text-blue-500 mr-2"></i> 权重管理
                                </h4>
                                <p class="text-gray-700">支持基于缓存项大小的权重控制</p>
                            </div>
                            <div class="bg-white p-4 rounded-lg shadow-sm">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-sync-alt text-blue-500 mr-2"></i> 异步加载
                                </h4>
                                <p class="text-gray-700">支持CompletableFuture异步加载数据</p>
                            </div>
                            <div class="bg-white p-4 rounded-lg shadow-sm">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-redo text-blue-500 mr-2"></i> 自动刷新
                                </h4>
                                <p class="text-gray-700">支持在过期前自动刷新缓存</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-8">
                        <h3 class="text-2xl font-semibold mb-4 text-gray-800">示例代码</h3>
                        <div class="code-block">
                            <div class="code-header">
                                <span class="text-gray-300">Java</span>
                                <button class="text-blue-400 hover:text-blue-300 text-sm">
                                    <i class="far fa-copy mr-1"></i>复制代码
                                </button>
                            </div>
                            <pre class="p-4 overflow-x-auto"><code class="language-java">Cache&lt;Integer, String&gt; cache = Caffeine.newBuilder()
    .maximumSize(1000)                // 最大缓存项数
    .maximumWeight(10000)             // 最大缓存权重
    .weigher((key, value) -> value.length())  // 权重计算方式
    .expireAfterWrite(10, TimeUnit.MINUTES)
    .build();</code></pre>
                        </div>
                    </div>
                </div>
                
                <div class="md:w-1/3">
                    <div class="bg-white p-6 rounded-lg shadow-sm sticky top-8">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800">性能优势</h3>
                        <ul class="space-y-4">
                            <li class="flex items-start">
                                <div class="flex-shrink-0 h-5 w-5 text-blue-500">
                                    <i class="fas fa-check-circle"></i>
                                </div>
                                <p class="ml-3 text-gray-700">高并发环境下性能优异</p>
                            </li>
                            <li class="flex items-start">
                                <div class="flex-shrink-0 h-5 w-5 text-blue-500">
                                    <i class="fas fa-check-circle"></i>
                                </div>
                                <p class="ml-3 text-gray-700">优化的内存管理和回收策略</p>
                            </li>
                            <li class="flex items-start">
                                <div class="flex-shrink-0 h-5 w-5 text-blue-500">
                                    <i class="fas fa-check-circle"></i>
                                </div>
                                <p class="ml-3 text-gray-700">支持多种高级缓存策略</p>
                            </li>
                            <li class="flex items-start">
                                <div class="flex-shrink-0 h-5 w-5 text-blue-500">
                                    <i class="fas fa-check-circle"></i>
                                </div>
                                <p class="ml-3 text-gray-700">基于Java 8现代化设计</p>
                            </li>
                        </ul>
                        
                        <h3 class="text-xl font-semibold mt-8 mb-4 text-gray-800">最佳适用场景</h3>
                        <div class="flex flex-wrap gap-2">
                            <span class="feature-tag bg-blue-100 text-blue-800">高并发应用</span>
                            <span class="feature-tag bg-blue-100 text-blue-800">低延迟需求</span>
                            <span class="feature-tag bg-blue-100 text-blue-800">大数据量缓存</span>
                            <span class="feature-tag bg-blue-100 text-blue-800">性能敏感场景</span>
                        </div>
                        
                        <div class="mt-8">
                            <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1740727256729-e27552ca-ab39-4a87-b1c2-55da6e84a137.png" alt="Caffeine" class="rounded-lg shadow-md w-full">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Redis Section -->
    <section class="py-16 px-4 sm:px-6 lg:px-8 bg-white">
        <div class="max-w-5xl mx-auto">
            <div class="flex flex-col md:flex-row gap-12">
                <div class="md:w-2/3">
                    <div class="flex items-center mb-8">
                        <div class="tech-icon bg-red-100 text-red-600 mr-4">
                            <i class="fas fa-server text-2xl"></i>
                        </div>
                        <h2 class="text-3xl font-bold text-gray-800">Redis</h2>
                    </div>
                    
                    <p class="text-lg text-gray-700 mb-6"><span class="font-semibold">Redis</span>（Remote Dictionary Server）是一个开源的、高性能的键值对数据库，广泛用于缓存和持久化存储。它本质上是一个基于内存的 NoSQL 数据库，提供了丰富的数据结构和高效的读写性能，广泛应用于分布式系统中，尤其是在需要高并发、低延迟、数据持久化和高可用性的场景下。</p>
                    
                    <div class="mb-8">
                        <h3 class="text-2xl font-semibold mb-4 text-gray-800">核心特性</h3>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                            <div class="bg-gray-50 p-4 rounded-lg">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-boxes text-red-500 mr-2"></i> 丰富数据结构
                                </h4>
                                <p class="text-gray-700">字符串、哈希、列表、集合、有序集合等</p>
                            </div>
                            <div class="bg-gray-50 p-4 rounded-lg">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-network-wired text-red-500 mr-2"></i> 分布式支持
                                </h4>
                                <p class="text-gray-700">集群模式、主从复制、哨兵高可用</p>
                            </div>
                            <div class="bg-gray-50 p-4 rounded-lg">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-save text-red-500 mr-2"></i> 持久化存储
                                </h4>
                                <p class="text-gray-700">RDB快照和AOF日志两种持久化方式</p>
                            </div>
                            <div class="bg-gray-50 p-4 rounded-lg">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-tachometer-alt text-red-500 mr-2"></i> 高性能
                                </h4>
                                <p class="text-gray-700">基于内存操作，每秒可处理数百万请求</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-8">
                        <h3 class="text-2xl font-semibold mb-4 text-gray-800">数据操作示例</h3>
                        <div class="code-block">
                            <div class="code-header">
                                <span class="text-gray-300">Redis CLI</span>
                                <button class="text-blue-400 hover:text-blue-300 text-sm">
                                    <i class="far fa-copy mr-1"></i>复制代码
                                </button>
                            </div>
                            <pre class="p-4 overflow-x-auto"><code class="language-bash"># 字符串操作
SET mykey "Hello, Redis!"
GET mykey

# 哈希操作
HSET user:1000 name "John" age 30
HGET user:1000 name
HGETALL user:1000

# 列表操作
LPUSH mylist "apple"
RPUSH mylist "banana"
LPOP mylist

# 集合操作
SADD myset "apple" "banana"
SMEMBERS myset
SPOP myset

# 有序集合操作
ZADD leaderboard 100 "Alice" 200 "Bob"
ZRANGE leaderboard 0 -1 WITHSCORES</code></pre>
                        </div>
                    </div>
                </div>
                
                <div class="md:w-1/3">
                    <div class="bg-gray-50 p-6 rounded-lg sticky top-8">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800">核心价值</h3>
                        <ul class="space-y-4">
                            <li class="flex items-start">
                                <div class="flex-shrink-0 h-5 w-5 text-red-500">
                                    <i class="fas fa-check-circle"></i>
                                </div>
                                <p class="ml-3 text-gray-700">分布式架构，支持高可用</p>
                            </li>
                            <li class="flex items-start">
                                <div class="flex-shrink-0 h-5 w-5 text-red-500">
                                    <i class="fas fa-check-circle"></i>
                                </div>
                                <p class="ml-3 text-gray-700">数据持久化，防止数据丢失</p>
                            </li>
                            <li class="flex items-start">
                                <div class="flex-shrink-0 h-5 w-5 text-red-500">
                                    <i class="fas fa-check-circle"></i>
                                </div>
                                <p class="ml-3 text-gray-700">支持多种数据结构</p>
                            </li>
                            <li class="flex items-start">
                                <div class="flex-shrink-0 h-5 w-5 text-red-500">
                                    <i class="fas fa-check-circle"></i>
                                </div>
                                <p class="ml-3 text-gray-700">极高的读写性能</p>
                            </li>
                        </ul>
                        
                        <h3 class="text-xl font-semibold mt-8 mb-4 text-gray-800">典型应用场景</h3>
                        <div class="flex flex-wrap gap-2">
                            <span class="feature-tag bg-red-100 text-red-800">分布式缓存</span>
                            <span class="feature-tag bg-red-100 text-red-800">会话存储</span>
                            <span class="feature-tag bg-red-100 text-red-800">消息队列</span>
                            <span class="feature-tag bg-red-100 text-red-800">实时分析</span>
                            <span class="feature-tag bg-red-100 text-red-800">排行榜</span>
                        </div>
                        
                        <div class="mt-8">
                            <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1740727277391-1306befb-35dd-4d97-85e4-bbeb6b6a172e.png" alt="Redis" class="rounded-lg shadow-md w-full">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Comparison Section -->
    <section class="py-16 px-4 sm:px-6 lg:px-8 bg-gray-50">
        <div class="max-w-5xl mx-auto">
            <div class="text-center mb-12">
                <h2 class="text-3xl font-bold text-gray-800 mb-4">技术对比：Guava Cache vs Caffeine vs Redis</h2>
                <p class="text-xl text-gray-600 max-w-3xl mx-auto">每种缓存解决方案都在不同场景下有其独特的优势，选择合适的缓存技术需要根据项目的具体需求来决定。</p>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                <div class="p-8">
                    <div class="overflow-x-auto">
                        <table class="comparison-table">
                            <thead>
                                <tr>
                                    <th>特性</th>
                                    <th>Guava Cache</th>
                                    <th>Caffeine</th>
                                    <th>Redis</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td><strong>缓存类型</strong></td>
                                    <td>内存缓存</td>
                                    <td>高性能内存缓存</td>
                                    <td>内存数据库，支持分布式缓存</td>
                                </tr>
                                <tr>
                                    <td><strong>分布式支持</strong></td>
                                    <td><i class="fas fa-times text-red-500"></i> 不支持</td>
                                    <td><i class="fas fa-times text-red-500"></i> 不支持</td>
                                    <td><i class="fas fa-check text-green-500"></i> 支持(Cluster, Sentinel)</td>
                                </tr>
                                <tr>
                                    <td><strong>性能</strong></td>
                                    <td>中等</td>
                                    <td>高性能，低延迟</td>
                                    <td>非常高，适用于高并发</td>
                                </tr>
                                <tr>
                                    <td><strong>扩展性</strong></td>
                                    <td>仅单机应用</td>
                                    <td>仅单机应用</td>
                                    <td>极好，支持水平扩展</td>
                                </tr>
                                <tr>
                                    <td><strong>持久化</strong></td>
                                    <td><i class="fas fa-times text-red-500"></i> 不支持</td>
                                    <td><i class="fas fa-times text-red-500"></i> 不支持</td>
                                    <td><i class="fas fa-check text-green-500"></i> 支持(RDB, AOF)</td>
                                </tr>
                                <tr>
                                    <td><strong>适用场景</strong></td>
                                    <td>小型单机应用，轻量级缓存</td>
                                    <td>高并发、高吞吐量的单机应用</td>
                                    <td>分布式缓存、大数据量、高可用</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    
                    <div class="mt-12">
                        <h3 class="text-2xl font-semibold mb-6 text-gray-800">技术选型建议</h3>
                        <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                            <div class="bg-purple-50 p-6 rounded-lg">
                                <h4 class="text-xl font-semibold mb-4 text-purple-800 flex items-center">
                                    <i class="fas fa-memory mr-2"></i> Guava Cache
                                </h4>
                                <ul class="space-y-3">
                                    <li class="flex items-start">
                                        <div class="flex-shrink-0 h-5 w-5 text-purple-500">
                                            <i class="fas fa-check"></i>
                                        </div>
                                        <p class="ml-2 text-gray-700">单机应用</p>
                                    </li>
                                    <li class="flex items-start">
                                        <div class="flex-shrink-0 h-5 w-5 text-purple-500">
                                            <i class="fas fa-check"></i>
                                        </div>
                                        <p class="ml-2 text-gray-700">轻量级缓存需求</p>
                                    </li>
                                    <li class="flex items-start">
                                        <div class="flex-shrink-0 h-5 w-5 text-purple-500">
                                            <i class="fas fa-check"></i>
                                        </div>
                                        <p class="ml-2 text-gray-700">快速开发与集成</p>
                                    </li>
                                </ul>
                            </div>
                            <div class="bg-blue-50 p-6 rounded-lg">
                                <h4 class="text-xl font-semibold mb-4 text-blue-800 flex items-center">
                                    <i class="fas fa-bolt mr-2"></i> Caffeine
                                </h4>
                                <ul class="space-y-3">
                                    <li class="flex items-start">
                                        <div class="flex-shrink-0 h-5 w-5 text-blue-500">
                                            <i class="fas fa-check"></i>
                                        </div>
                                        <p class="ml-2 text-gray-700">高并发单机应用</p>
                                    </li>
                                    <li class="flex items-start">
                                        <div class="flex-shrink-0 h-5 w-5 text-blue-500">
                                            <i class="fas fa-check"></i>
                                        </div>
                                        <p class="ml-2 text-gray-700">低延迟需求</p>
                                    </li>
                                    <li class="flex items-start">
                                        <div class="flex-shrink-0 h-5 w-5 text-blue-500">
                                            <i class="fas fa-check"></i>
                                        </div>
                                        <p class="ml-2 text-gray-700">大数据量缓存</p>
                                    </li>
                                </ul>
                            </div>
                            <div class="bg-red-50 p-6 rounded-lg">
                                <h4 class="text-xl font-semibold mb-4 text-red-800 flex items-center">
                                    <i class="fas fa-server mr-2"></i> Redis
                                </h4>
                                <ul class="space-y-3">
                                    <li class="flex items-start">
                                        <div class="flex-shrink-0 h-5 w-5 text-red-500">
                                            <i class="fas fa-check"></i>
                                        </div>
                                        <p class="ml-2 text-gray-700">分布式应用</p>
                                    </li>
                                    <li class="flex items-start">
                                        <div class="flex-shrink-0 h-5 w-5 text-red-500">
                                            <i class="fas fa-check"></i>
                                        </div>
                                        <p class="ml-2 text-gray-700">高可用需求</p>
                                    </li>
                                    <li class="flex items-start">
                                        <div class="flex-shrink-0 h-5 w-5 text-red-500">
                                            <i class="fas fa-check"></i>
                                        </div>
                                        <p class="ml-2 text-gray-700">持久化存储</p>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Mermaid Diagram -->
    <section class="py-16 px-4 sm:px-6 lg:px-8 bg-white">
        <div class="max-w-5xl mx-auto">
            <div class="text-center mb-12">
                <h2 class="text-3xl font-bold text-gray-800 mb-4">缓存技术关系图</h2>
                <p class="text-xl text-gray-600 max-w-3xl mx-auto">使用Mermaid.js可视化展示三种缓存技术的关系与特性</p>
            </div>
            
            <div class="bg-gray-50 p-8 rounded-lg">
                <div class="mermaid">
                    graph TD
                    A[Java缓存技术] --> B[Guava Cache]
                    A --> C[Caffeine]
                    A --> D[Redis]
                    
                    B --> E[本地缓存]
                    C --> E
                    D --> F[分布式缓存]
                    
                    B --> G[自动过期]
                    B --> H[线程安全]
                    B --> I[内存管理]
                    
                    C --> G
                    C --> H
                    C --> I
                    C --> J[高性能算法]
                    C --> K[权重管理]
                    
                    D --> L[多种数据结构]
                    D --> M[持久化]
                    D --> N[高可用]
                    D --> O[集群支持]
                    
                    style A fill:#f0f9ff,stroke:#0369a1
                    style B fill:#f5f3ff,stroke:#7e22ce
                    style C fill:#eff6ff,stroke:#1d4ed8
                    style D fill:#fee2e2,stroke:#dc2626
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-6 md:mb-0">
                    <h3 class="text-xl font-bold">技术小馆</h3>
                    <p class="text-gray-400 mt-2">探索技术之美，分享开发经验</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-150 ease-in-out flex items-center">
                        <i class="fas fa-globe mr-2"></i> http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-400 text-sm">
                <p>© 2023 技术小馆. All rights reserved.</p>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            fontFamily: 'Noto Sans SC, sans-serif'
        });
        
        // 复制代码功能
        document.querySelectorAll('.code-header button').forEach(button => {
            button.addEventListener('click', () => {
                const codeBlock = button.closest('.code-block');
                const code = codeBlock.querySelector('code').textContent;
                navigator.clipboard.writeText(code).then(() => {
                    const originalText = button.innerHTML;
                    button.innerHTML = '<i class="fas fa-check mr-1"></i>已复制';
                    setTimeout(() => {
                        button.innerHTML = originalText;
                    }, 2000);
                });
            });
        });
    </script>
</body>
</html>